package dst1.model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name="GRID",
	uniqueConstraints = @UniqueConstraint(columnNames={"NAME"}))
public class Grid implements Serializable{

	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="ID") 
	private Long id;
	
	@Column(unique=true, name="NAME")
	private String name;
	
	@Column(name="LOCATION") 
	private String location;
	
	@Column(name="COSTSPERCPUMINUTE") 
	private BigDecimal costsPerCPUMinute;
	
	@OneToMany(cascade=CascadeType.ALL, mappedBy="grid", fetch=FetchType.LAZY)
	private List<Cluster> clusters;
	
	@OneToMany(cascade=CascadeType.ALL, mappedBy="grid", fetch=FetchType.LAZY)
	private List<Membership> membership;
	
	public Grid(){
		
	}

	public Grid( String name, String location,
			BigDecimal costsPerCPUMinute, List<Cluster> clusters,
			List<Membership> membership) {
		super();
		this.name = name;
		this.location = location;
		this.costsPerCPUMinute = costsPerCPUMinute;
		this.clusters = clusters;
		this.membership = membership;
	}

	public Long getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public BigDecimal getCostsPerCPUMinute() {
		return costsPerCPUMinute;
	}

	public void setCostsPerCPUMinute(BigDecimal costsPerCPUMinute) {
		this.costsPerCPUMinute = costsPerCPUMinute;
	}

	public List<Cluster> getClusters() {
		return clusters;
	}

	public void setClusters(List<Cluster> clusters) {
		this.clusters = clusters;
	}

	public List<Membership> getMembership() {
		return membership;
	}

	public void setMembership(List<Membership> membership) {
		this.membership = membership;
	}
	

	
}
